package com.oauth.google.server.shared;

import java.util.ArrayList;
import java.util.List;

import com.google.gdata.data.docs.DocumentListEntry;
import com.oauth.google.client.beans.docs.GoogleDocument;

public class GoogleDocUtil {

	public static List<GoogleDocument> convertToEntries(
			List<DocumentListEntry> entries) {
		List<GoogleDocument> documents = new ArrayList<GoogleDocument>();
		for (DocumentListEntry entry : entries) {
			documents.add(convertToEntry(entry));
		}
		return documents;
	}

	public static GoogleDocument convertToEntry(DocumentListEntry pEntry) {
		GoogleDocument document = new GoogleDocument();
		document.setResourceId(pEntry.getResourceId());
		document.setLink(pEntry.getDocumentLink().getHref());
		document.setTitle(pEntry.getTitle().getPlainText());
		return document;
	}

}
